<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <script src="js/jquery3.6.0.js" type="text/javascript"></script>
</head>
<body>
    <#if admin??>
        欢迎您 <span style="font-weight: bolder;">${admin.nickname}</span>  <br>
        <div style="border: 1px solid red;float: right;padding: 3px;">
            <a href="update_password.html">修改密码</a> <br>
            <a href="admin.ftl">用户详情</a> <br>
            <a href="user_add.html">注册新用户</a> <br>

            <a href="user?op=logout">退出登录</a>
        </div>
        <table style="width: 80%;">
            <tr>
                <th>编号</th>
                <th>姓名</th>
                <th>性别</th>
                <th>电话</th>
                <th>积分</th>
            </tr>
            <#list userPageBean.records as user>
                <tr>
                    <td> ${user.id}</td>
                    <td>${user.name}</td>
                    <td><#if user.gender>男 <#else>女</#if></td>
                    <td>${user.tel}</td>
                    <td>${user.credits}</td>
                </tr>
            </#list>
            <tr>
                <td colspan="5" style="text-align: center;">
                    <#list 1..userPageBean.pages as i>
                       <span style="margin-right: 23px;">
                            <a href="javascript:void(0);" class="pageNum">${i}</a>
                       </span>
                    </#list>

                    <select name="pageSize" id="pageSize">
<#--                        <option value="10"<#if pageSize==10>selected</#if>>10</option>-->
<#--                        <option value="20"<#if pageSize==20>selected</#if>>20</option>-->
<#--                        <option value="30"<#if pageSize==30>selected</#if>>30</option>-->
<#--                        <option value="40"<#if pageSize==40>selected</#if>>40</option>-->
                        <option value="10">10</option>
                        <option value="20">20</option>
                        <option value="30">30</option>
                        <option value="40">40</option>
                    </select>
                </td>
            </tr>
        </table>
    <#else>
        <a href="login.ftl">登录</a>
    </#if>

    <script type="text/javascript">
        $(".pageNum").click(function (){
          //$("#pageSize") ID选择器
          let pageSize = $("#pageSize").val();
          // alert(pageSize)

          let pageNum = $(this).text()
          // alert(pageNum)

          document.location.href="user?op=getPage&pageSize="+pageSize+"&pageNum="+pageNum
        });

    </script>
</body>
</html>